package dao

type Managerelation struct {
	Mid int `gorm:"type:int" json:"mid" form:"mid"`
	Cid int `gorm:"type:int" json:"cid" form:"cid"`
}

func (m *Managerelation) FindCidByMid(mid int) (list []Managerelation) {
	db.Where("mid=?", mid).Find(&list)
	return
}

func (m *Managerelation) Insert(mrs []Managerelation) (err error) {
	tx := db.Begin()
	db.Where("mid=?", m.Mid).Delete(&m)
	err = db.Create(&mrs).Error
	if err != nil {
		tx.Rollback()
		return
	}
	tx.Commit()
	return
}
